package com.party.controller.app;


import com.party.common.base.ApiResult;
import com.party.common.entity.MyPage;
import com.party.entity.PbResource;
import com.party.entity.dto.DistributeDto1;
import com.party.entity.dto.PublishBannerDto;
import com.party.entity.dto.QueryResourceDto;
import com.party.service.PbResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 资源 前端控制器
 * </p>
 *
 * @author ccl
 * @since 2024-10-25
 */
@RestController("AppPbResourceController")
@RequestMapping("app/pb-resource")
@Api(tags = "小程序资源api接口", value = "小程序资源api接口")
public class PbResourceController {

    @Resource
    private PbResourceService pbResourceService;

    @PostMapping("queryPage")
    @ApiOperation("分页查询")
    public ApiResult<MyPage<PbResource>> queryPage(@RequestBody QueryResourceDto dto){
        MyPage<PbResource> page = pbResourceService.queryAppPage(dto);
        return ApiResult.ok(page);
    }

    @GetMapping("detail")
    @ApiOperation(value = "详情",response = PbResource.class)
    public ApiResult detail(Long id,String openId){
        return ApiResult.ok(pbResourceService.detailWx(id,openId));
    }


    @GetMapping("/downloadAndParseEpub")
    @ApiOperation(value = "epub图书进行阅读")
    public ApiResult<String> downloadAndParseEpub(String url) {
        return ApiResult.ok(pbResourceService.downloadAndParseEpub(url));
    }

    @GetMapping("/hotRecommend")
    @ApiOperation(value = "热门推荐")
    public ApiResult<List<PbResource>> hotRecommend () {
        return ApiResult.ok(pbResourceService.hotRecommend());
    }
    @GetMapping("/downloadAndParseEpub1")
    @ApiOperation(value = "epub图书进行阅读")
    public ApiResult<String> downloadAndParseEpub1(String url) {
        return ApiResult.ok1(pbResourceService.downloadAndParseEpub(url));
    }
}

